package cn.wonderland.controller;


import cn.wonderland.dto.OrderListDto;
import cn.wonderland.service.OrderService;
import cn.wonderland.utils.JSONResult;
import cn.wonderland.vo.orderlist.OrderListVo;
import cn.wonderland.vo.orderlist.TypeOrderListVo;
import cn.wonderland.vo.report.ReportVo;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/getOrderList")
    public JSONResult<List<TypeOrderListVo>> getOrderList(@RequestBody OrderListDto dto) {
        return orderService.getOrderList(dto);
    }

    @GetMapping("/report")
    public JSONResult<List<ReportVo>> report(@RequestBody OrderListDto dto) {
        List<ReportVo> report = orderService.report(dto);
        return JSONResult.<List<ReportVo>>builder()
                .message("请求成功")
                .code(200)
                .success(true)
                .data(report)
                .build();
    }
}
